<?php

namespace app\common\model;

use think\Model;
use think\Db;

/**
 * 秒杀模型
 */
class FlashSale extends Model
{
    protected $append = [
        'store_count'
    ];

    public function goods()
    {
        return $this->belongsTo('goods','id','prom_id')->field('id,image,market_price,prom_type,prom_id');
    }

    //剩余抢购库存
    public function getStoreCountAttr($value, $data)
    {
        return $data['goods_num'] - $data['buy_num'];
    }



}